#ifndef UUID_34F49C6CBF234C1D12B368B61CA79917
#define UUID_34F49C6CBF234C1D12B368B61CA79917

#include "flip.hpp"

extern "C"
{
#include "lauxlib.h"
#include "lualib.h"
#include "luajit.h"
#include "luaext.h"
}

#include "../luautil/luautil.hpp"

#include "window.hpp"
#include "font.hpp"

#include <flip/2d/geom_buffer.hpp>

#include <flip/2d/renderable_image.hpp>
#include <flip/raster/image.hpp>

#define LUAF(name) extern "C" int luaflip_##name(lua_State* L)
#define LUAN(name) {#name, luaflip_##name}
#define LUAN2(name1, name2) {#name1, luaflip_##name2}

LUAF(video);
LUAF(update);
LUAF(end_drawing);
LUAF(next_event);
LUAF(throttle_fps);
LUAF(close);

LUAF(begin_quads);
LUAF(quad);
LUAF(begin_sprites);
LUAF(sprite);
LUAF(sprite_centered);
LUAF(sprite_centered_rot);
LUAF(clear);
LUAF(color);

LUAF(create_image);
LUAF(load_image);
LUAF(to_sprite);
LUAF(draw_sprite);
LUAF(setpixel);
LUAF(image_dim);
LUAF(image_gc);
LUAF(sprite_gc);

LUAF(load_font);
LUAF(text);
LUAF(font_gc);

LUAF(lua_test_flush_buffers); // Test

extern int flip_image_tag;
extern int flip_sprite_tag;
extern int flip_font_tag;

struct luaflipData
{
	luaflipData()
	: drawBuffer(currentWindow)
	{
	}

	LuaWindow currentWindow;
	Flip::GeomBuffer drawBuffer;

	// Testing

};

extern luaflipData globalDataInstance;

inline luaflipData& globalData(lua_State* L)
{
#if 0
	return *(luaflipData*)lua_touserdata(L, lua_upvalueindex(1));
#else
	return globalDataInstance;
#endif
}

LUA_CHECK_FUNC(Flip::Image, image, flip_image_tag)
LUA_CHECK_FUNC(Flip::RenderableImage, sprite, flip_sprite_tag)
LUA_CHECK_FUNC(Flip::Font, font, flip_font_tag)

#endif // UUID_34F49C6CBF234C1D12B368B61CA79917
